//
//  ECMineProfileTypeOneCell.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/16.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECMineProfileTypeOneCell.h"

@interface ECMineProfileTypeOneCell(){
    ///typeLab
    UILabel *typeLab;
    ///头像image
    UIImageView *iconImage;
    ///内容lab
    UILabel *contentLab;
    UIView *lineView;
    ///箭头image
    UIImageView *arrowView;
}

@end

@implementation ECMineProfileTypeOneCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        
        [self setCellUI];
    }
    return self;
}

-(void)setCellUI{
    typeLab = [[UILabel alloc]init];
    [self.contentView addSubview:typeLab];
    typeLab.textColor = [UIColor colorWithHexString:@"#999999"];
    
    iconImage = [[UIImageView alloc]init];
    [self.contentView addSubview:iconImage];
    iconImage.backgroundColor = [UIColor orangeColor];
    iconImage.layer.masksToBounds = YES;
    iconImage.layer.cornerRadius = kProportion_Width(80);
    
    contentLab = [[UILabel alloc]init];
    [self.contentView addSubview:contentLab];
    contentLab.textAlignment = NSTextAlignmentRight;
    contentLab.textColor = [UIColor colorWithHexString:@"#1a1a1a"];
    
    arrowView = [[UIImageView alloc]init];
    [self.contentView addSubview:arrowView];
    [arrowView setImage:[UIImage imageNamed:@"MIne_safeArrow"]];
    
    lineView = [[UIView alloc]init];
    [self.contentView addSubview:lineView];
    lineView.backgroundColor = [UIColor colorWithHexString:@"#E6E6E6"];
    
    WeakSelf(weakSelf);
    [typeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.contentView.mas_centerY);
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kProportion_Width(45));
        make.width.equalTo(@100);
        make.height.equalTo(@18);
    }];
    
    [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(typeLab.mas_centerY);
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.width.and.height.equalTo(@(kProportion_Width(160)));
    }];
    
    [arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kProportion_Width(45));
        make.centerY.equalTo(typeLab.mas_centerY);
        make.width.equalTo(@(kProportion_Width(17)));
        make.height.equalTo(arrowView.mas_width).multipliedBy(38.f/17.f);
    }];
    
    [contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(arrowView.mas_right).offset(-10);
        make.centerY.equalTo(typeLab.mas_centerY);
        make.width.equalTo(@150);
        make.height.equalTo(@17);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.contentView.mas_bottom);
        make.left.equalTo(typeLab.mas_left);
        make.right.equalTo(arrowView.mas_right);
        make.height.equalTo(@1);
    }];
}

-(void)setContentWithData:(NSMutableArray *)nameArray andIndexPath:(NSIndexPath *)indexPath{
    typeLab.text = nameArray[indexPath.section][indexPath.row][0];
    contentLab.text = nameArray[indexPath.section][indexPath.row][1];
    if (indexPath.row == 0) {
        contentLab.hidden = YES;//隐藏介绍lab
        arrowView.hidden = YES;//隐藏箭头
        [iconImage sd_setImageWithURL:[NSURL URLWithString:nameArray[indexPath.section][indexPath.row][1]] placeholderImage:[UIImage imageNamed:@"Mine_iconImage"]];//加载图片
    }else{
        contentLab.hidden = NO;
        arrowView.hidden = NO;
        iconImage.hidden = YES;
    }
    
    if (indexPath.row == 3) {
        lineView.hidden = YES;
    }
    
    if (indexPath.row == 2) {//匹配性别
        if ([nameArray[indexPath.section][indexPath.row][1] isEqualToString:@"male"]) {
            contentLab.text = @"男";
        }else{
            contentLab.text = @"女";
        }
    }
    
}


@end
